package com.yoomiito.app.widget;

import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.yoomiito.app.utils.DensityUtil;

public class GridItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public GridItemDecoration(int space) {
        this.space = DensityUtil.dp2px(space);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {

        if (parent.getChildLayoutPosition(view)%2==0){
            outRect.set(0,0,space,space);
        }else {
            outRect.set(0,0,0,space);
        }

    }
}
